package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);


    // 分页查询
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);


    // 批量删除 使用动态 SQL
    void deleteBatch(List<Long> ids);

    // 插入数据
    @AutoFill(value = OperationType.INSERT)
    void insert(Setmeal setmeal);

    // 根据主键id查询
    @Select("select * from setmeal where id = #{id}")
    Setmeal queryById(Long id);


    //修改员工信息,动态修改
    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    // 根据分类id查询
    @Select("select * from setmeal where category_id = #{categoryId} and status = 1")
    List<Setmeal> queryByCategoryId(Integer categoryId);


    // 统计
    Integer countByMap(Map map);

}
